﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Wicresoft.UnifyShow.Business;
using Microsoft.Practices.Unity;
using Wicresoft.UnifyShow.Portal.ViewModels;

namespace Wicresoft.UnifyShow.Portal.Controllers
{
    public class ToDoTableController : BaseController
    {
        private IUser_X user;

        protected override void Dispose(bool disposing)
        {
            ((IDisposable)user).Dispose();
        }

        [InjectionConstructor]
        public ToDoTableController(IUser_X user)
        {
            this.user = user;
        }

        //
        // GET: /ToDoTable/

        public ActionResult Table(int page = 1)
        {
            base.SetRoles(user);
            int pageSize = 15, count;

            var todos = ToDoHelper.GetListToDo(UserLoginID, out count, page, pageSize);

            return PartialView(new PagedToDoModel()
            {
                ToDos = todos,
                PageNumber = page,
                PageSize = pageSize,
                TotalRows = count
            });
        }

    }
}
